package com.example.springbootusecase.controller;

import com.example.springbootusecase.hardware.MicrophoneRecorder;
import com.example.springbootusecase.hardware.PlayLocalAudio;
import com.example.springbootusecase.hardware.SpeakerExample;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.sound.sampled.AudioFileFormat;

@Slf4j
@RestController
@RequestMapping("/hardware")
public class HardwareController {

    @PostMapping("/record")
    public void record() throws Exception {
        MicrophoneRecorder microphoneRecorder = new MicrophoneRecorder();
        String file = microphoneRecorder.microphoneRecorder();
        PlayLocalAudio.playAudio(file);
    }
}
